﻿using Infrastructure.States;
using Logic;
using UnityEngine;

namespace Hero
{
    public class HeroDeath : MonoBehaviour
    {
        [SerializeField] private HeroHealth _health;
        private GameStateMachine _stateMachine;

        public void Construct(GameStateMachine stateMachine) =>
            _stateMachine = stateMachine;

        private void Start() =>
            _health.Destroyed += Die;

        private void Die() =>
            _stateMachine.Enter<LoadEndGameState, string>(Constants.EndGame);
    }
}